package com.bang.study.spring.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @ClassName: Blue
 * @author: BANG
 * @Date: 2019/11/13 10:11
 * @Version: 1.0
 * @Modified By:
 * @Desc: TODO
 */
public class Blue implements ApplicationContextAware,InitializingBean,DisposableBean {

    private ApplicationContext applicationContext;

    private String name;

    private String rgb;

    @PostConstruct
    public void postConstruct() {
        System.out.println("--------------PostConstruct---------------");
        this.name = "蓝色";
        this.rgb = "0,0,0";
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("--------------PreDestroy---------------");
    }

    public void init() {
        System.out.println("--------------init---------------");
    }

    public void destory() {
        System.out.println("--------------destory---------------");
    }




    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("===========================afterPropertiesSet");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("===========================destroy");
    }


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRgb() {
        return rgb;
    }

    public void setRgb(String rgb) {
        this.rgb = rgb;
    }

    @Override
    public String toString() {
        return "Blue{" +
                "applicationContext=" + applicationContext +
                ", name='" + name + '\'' +
                ", rgb='" + rgb + '\'' +
                '}';
    }
}
